package transmit

import (
	"fmt"
	"net"
	"os"
)

func sendServerSource(conn net.Conn, sourceData []byte) {
	_, err := conn.Write(sourceData)
	if err != nil {
		fmt.Println(err)
		return
	}
	print("Running...\n")
	receiveResult(conn)
}

func SendServerFile(filename string) {
	conn := connectionBuild()
	defer conn.Close()
	fn, _ := os.OpenFile(filename, os.O_RDONLY, 0777)
	defer fn.Close()
	filedata := make([]byte, 8196, 8196)
	_, err := fn.Read(filedata)
	if err != nil {
		fmt.Println(err)
		return
	}
	println("Sending...")
	sendServerSource(conn, filedata)

}
